3.8. Classification Test #3

In [1]:
import sdm as sdmlib
import matplotlib.pyplot as plt
from PIL import Image, ImageDraw, ImageFont
import urllib, cStringIO
import random
from IPython.core.display import display, Image as IPythonImage
%matplotlib inline
In [2]:
width = 31
height = 32
noise_flip = True
In [3]:
def gen_img(letter='A'):
    img = Image.new('RGBA', (width, height), (255, 255, 255))
    font = ImageFont.truetype('Arial.ttf', 30)
    draw = ImageDraw.Draw(img)
    w, h = draw.textsize(letter, font=font)
    top = (height-w)//2
    left = (width-h)//2 if h <= 30 else 30-2-h
    draw.text((top, left), letter, (0, 0, 0), font=font)
    return img
In [4]:
def gen_noise_add(img, p=0.15, flip=False):
    img2 = img.copy()
    draw = ImageDraw.Draw(img2)
    for py in xrange(height):
        for px in xrange(width):
            if random.random() < p:
                if flip:
                    pixel = img.getpixel((px, py))
                    value = sum([int(x/255+0.5) for x in pixel[:3]])//3
                    assert value == 0 or value == 1
                    value = (1 - value)*255
                    draw.point((px, py), fill=(value, value, value))
                else:
                    draw.point((px, py), fill=(0, 0, 0))
    return img2
In [5]:
img = gen_img(letter='R');
img2 = gen_noise_add(img, p=0.05, flip=noise_flip)
plt.subplot(1, 2, 1)
plt.imshow(img)
plt.subplot(1, 2, 2)
plt.imshow(img2);
../_images/notebooks_Classification_Test_3_5_0.png
In [6]:
def to_bitstring(img):
    v = []
    bs = sdmlib.Bitstring.init_ones(1000)
    for py in xrange(height):
        for px in xrange(width):
            pixel = img.getpixel((px, py))
            value = sum([int(x/255+0.5) for x in pixel[:3]])//3
            assert value == 0 or value == 1
            idx = px+width*py
            assert idx >= 0 and idx < 1000, 'Ops {} {} {}'.format(x, y, idx)
            bs.set_bit(idx, value)
            v.append(value)
    v2 = [bs.get_bit(i) for i in xrange(height*width)]
    assert v == v2
    return bs
In [7]:
def to_img(bs):
    img = Image.new('RGBA', (30, 30), (255, 255, 255))
    draw = ImageDraw.Draw(img)
    for py in xrange(height):
        for px in xrange(width):
            idx = px+width*py
            assert idx >= 0 and idx < 1000, 'Ops {} {} {}'.format(x, y, idx)
            x = 255*bs.get_bit(idx)
            draw.point((px, py), fill=(x, x, x))
    return img
In [8]:
bits = 1000
sample = 1000000
scanner_type = sdmlib.SDM_SCANNER_OPENCL
In [9]:
address_space = sdmlib.AddressSpace.init_from_b64_file('sdm-letters.as')
In [10]:
counter = sdmlib.Counter.create_file('sdm-classification-3', bits, sample)
sdm = sdmlib.SDM(address_space, counter, 451, scanner_type)
In [11]:
def fill_memory(letter, label_bs, p=0.1, n=100):
    cols = 15
    rows = n//cols + 1
    plt.figure(figsize=(20,10))
    for i in xrange(n):
        img = gen_img(letter=letter);
        img2 = gen_noise_add(img, p=p, flip=noise_flip)
        #display(img2)
        plt.subplot(rows, cols, i+1)
        plt.imshow(img2)
        bs = to_bitstring(img2)
        sdm.write(bs, label_bs)
    plt.show()
In [12]:
def read(letter, n=6, p=0.2, radius=None):
    img = gen_img(letter=letter);
    img2 = gen_noise_add(img, p=p, flip=noise_flip)
    plt.imshow(img2)

    bs2 = to_bitstring(img2)
    bs3 = sdm.read(bs2, radius=radius)

    label = min(label_to_bs.items(), key=lambda v: bs3.distance_to(v[1]))
    return label[0]
In [13]:
def iter_read(letter, n=10, p=0.2):
    cols = 15
    rows = n//cols + 1
    plt.figure(figsize=(20,10))

    wrong = 0
    correct = 0
    answers = []
    for i in xrange(n):
        plt.subplot(rows, cols, i+1)
        y = read(x, p=p)
        answers.append(y)
        if x == y:
            correct += 1
        else:
            wrong += 1
    plt.show()
    print '!! {} correct={:2d} wrong={:2d} answers={}'.format(x, correct, wrong, answers)

3.8.1. Generating labels

In [14]:
labels = list('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')
label_to_bs = {}
for x in labels:
    label_to_bs[x] = sdmlib.Bitstring.init_random(1000)

3.8.2. Training the SDM

In [15]:
for x in labels:
    print 'Training for label {}...'.format(x)
    fill_memory(x, label_to_bs[x])
Training for label A...
../_images/notebooks_Classification_Test_3_17_1.png
Training for label B...
../_images/notebooks_Classification_Test_3_17_3.png
Training for label C...
../_images/notebooks_Classification_Test_3_17_5.png
Training for label D...
../_images/notebooks_Classification_Test_3_17_7.png
Training for label E...
../_images/notebooks_Classification_Test_3_17_9.png
Training for label F...
../_images/notebooks_Classification_Test_3_17_11.png
Training for label G...
../_images/notebooks_Classification_Test_3_17_13.png
Training for label H...
../_images/notebooks_Classification_Test_3_17_15.png
Training for label I...
../_images/notebooks_Classification_Test_3_17_17.png
Training for label J...
../_images/notebooks_Classification_Test_3_17_19.png
Training for label K...
../_images/notebooks_Classification_Test_3_17_21.png
Training for label L...
../_images/notebooks_Classification_Test_3_17_23.png
Training for label M...
../_images/notebooks_Classification_Test_3_17_25.png
Training for label N...
../_images/notebooks_Classification_Test_3_17_27.png
Training for label O...
../_images/notebooks_Classification_Test_3_17_29.png
Training for label P...
../_images/notebooks_Classification_Test_3_17_31.png
Training for label Q...
../_images/notebooks_Classification_Test_3_17_33.png
Training for label R...
../_images/notebooks_Classification_Test_3_17_35.png
Training for label S...
../_images/notebooks_Classification_Test_3_17_37.png
Training for label T...
../_images/notebooks_Classification_Test_3_17_39.png
Training for label U...
../_images/notebooks_Classification_Test_3_17_41.png
Training for label V...
../_images/notebooks_Classification_Test_3_17_43.png
Training for label W...
../_images/notebooks_Classification_Test_3_17_45.png
Training for label X...
../_images/notebooks_Classification_Test_3_17_47.png
Training for label Y...
../_images/notebooks_Classification_Test_3_17_49.png
Training for label Z...
../_images/notebooks_Classification_Test_3_17_51.png
Training for label a...
../_images/notebooks_Classification_Test_3_17_53.png
Training for label b...
../_images/notebooks_Classification_Test_3_17_55.png
Training for label c...
../_images/notebooks_Classification_Test_3_17_57.png
Training for label d...
../_images/notebooks_Classification_Test_3_17_59.png
Training for label e...
../_images/notebooks_Classification_Test_3_17_61.png
Training for label f...
../_images/notebooks_Classification_Test_3_17_63.png
Training for label g...
../_images/notebooks_Classification_Test_3_17_65.png
Training for label h...
../_images/notebooks_Classification_Test_3_17_67.png
Training for label i...
../_images/notebooks_Classification_Test_3_17_69.png
Training for label j...
../_images/notebooks_Classification_Test_3_17_71.png
Training for label k...
../_images/notebooks_Classification_Test_3_17_73.png
Training for label l...
../_images/notebooks_Classification_Test_3_17_75.png
Training for label m...
../_images/notebooks_Classification_Test_3_17_77.png
Training for label n...
../_images/notebooks_Classification_Test_3_17_79.png
Training for label o...
../_images/notebooks_Classification_Test_3_17_81.png
Training for label p...
../_images/notebooks_Classification_Test_3_17_83.png
Training for label q...
../_images/notebooks_Classification_Test_3_17_85.png
Training for label r...
../_images/notebooks_Classification_Test_3_17_87.png
Training for label s...
../_images/notebooks_Classification_Test_3_17_89.png
Training for label t...
../_images/notebooks_Classification_Test_3_17_91.png
Training for label u...
../_images/notebooks_Classification_Test_3_17_93.png
Training for label v...
../_images/notebooks_Classification_Test_3_17_95.png
Training for label w...
../_images/notebooks_Classification_Test_3_17_97.png
Training for label x...
../_images/notebooks_Classification_Test_3_17_99.png
Training for label y...
../_images/notebooks_Classification_Test_3_17_101.png
Training for label z...
../_images/notebooks_Classification_Test_3_17_103.png
Training for label 0...
../_images/notebooks_Classification_Test_3_17_105.png
Training for label 1...
../_images/notebooks_Classification_Test_3_17_107.png
Training for label 2...
../_images/notebooks_Classification_Test_3_17_109.png
Training for label 3...
../_images/notebooks_Classification_Test_3_17_111.png
Training for label 4...
../_images/notebooks_Classification_Test_3_17_113.png
Training for label 5...
../_images/notebooks_Classification_Test_3_17_115.png
Training for label 6...
../_images/notebooks_Classification_Test_3_17_117.png
Training for label 7...
../_images/notebooks_Classification_Test_3_17_119.png
Training for label 8...
../_images/notebooks_Classification_Test_3_17_121.png
Training for label 9...
../_images/notebooks_Classification_Test_3_17_123.png

3.8.3. Testing with high noise

In [16]:
for x in 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789':
    iter_read(x)
../_images/notebooks_Classification_Test_3_19_0.png
!! A correct=10 wrong= 0 answers=['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A']
../_images/notebooks_Classification_Test_3_19_2.png
!! B correct= 9 wrong= 1 answers=['S', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B']
../_images/notebooks_Classification_Test_3_19_4.png
!! C correct=10 wrong= 0 answers=['C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C']
../_images/notebooks_Classification_Test_3_19_6.png
!! D correct=10 wrong= 0 answers=['D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D']
../_images/notebooks_Classification_Test_3_19_8.png
!! E correct=10 wrong= 0 answers=['E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E']
../_images/notebooks_Classification_Test_3_19_10.png
!! F correct=10 wrong= 0 answers=['F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F']
../_images/notebooks_Classification_Test_3_19_12.png
!! G correct=10 wrong= 0 answers=['G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G']
../_images/notebooks_Classification_Test_3_19_14.png
!! H correct=10 wrong= 0 answers=['H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H']
../_images/notebooks_Classification_Test_3_19_16.png
!! I correct=10 wrong= 0 answers=['I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I']
../_images/notebooks_Classification_Test_3_19_18.png
!! J correct=10 wrong= 0 answers=['J', 'J', 'J', 'J', 'J', 'J', 'J', 'J', 'J', 'J']
../_images/notebooks_Classification_Test_3_19_20.png
!! K correct=10 wrong= 0 answers=['K', 'K', 'K', 'K', 'K', 'K', 'K', 'K', 'K', 'K']
../_images/notebooks_Classification_Test_3_19_22.png
!! L correct=10 wrong= 0 answers=['L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L']
../_images/notebooks_Classification_Test_3_19_24.png
!! M correct=10 wrong= 0 answers=['M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M']
../_images/notebooks_Classification_Test_3_19_26.png
!! N correct=10 wrong= 0 answers=['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N']
../_images/notebooks_Classification_Test_3_19_28.png
!! O correct= 8 wrong= 2 answers=['G', 'G', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O']
../_images/notebooks_Classification_Test_3_19_30.png
!! P correct=10 wrong= 0 answers=['P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P']
../_images/notebooks_Classification_Test_3_19_32.png
!! Q correct=10 wrong= 0 answers=['Q', 'Q', 'Q', 'Q', 'Q', 'Q', 'Q', 'Q', 'Q', 'Q']
../_images/notebooks_Classification_Test_3_19_34.png
!! R correct=10 wrong= 0 answers=['R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R']
../_images/notebooks_Classification_Test_3_19_36.png
!! S correct=10 wrong= 0 answers=['S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S']
../_images/notebooks_Classification_Test_3_19_38.png
!! T correct= 9 wrong= 1 answers=['T', 'T', 'T', 'T', 'T', 'I', 'T', 'T', 'T', 'T']
../_images/notebooks_Classification_Test_3_19_40.png
!! U correct=10 wrong= 0 answers=['U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U']
../_images/notebooks_Classification_Test_3_19_42.png
!! V correct=10 wrong= 0 answers=['V', 'V', 'V', 'V', 'V', 'V', 'V', 'V', 'V', 'V']
../_images/notebooks_Classification_Test_3_19_44.png
!! W correct=10 wrong= 0 answers=['W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W']
../_images/notebooks_Classification_Test_3_19_46.png
!! X correct=10 wrong= 0 answers=['X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X']
../_images/notebooks_Classification_Test_3_19_48.png
!! Y correct= 9 wrong= 1 answers=['Y', 'I', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y']
../_images/notebooks_Classification_Test_3_19_50.png
!! Z correct=10 wrong= 0 answers=['Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z']
../_images/notebooks_Classification_Test_3_19_52.png
!! a correct=10 wrong= 0 answers=['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']
../_images/notebooks_Classification_Test_3_19_54.png
!! b correct= 3 wrong= 7 answers=['o', 'o', 'o', 'b', 'o', 'h', 'h', 'b', 'b', 'o']
../_images/notebooks_Classification_Test_3_19_56.png
!! c correct= 8 wrong= 2 answers=['c', 'c', 'c', 'c', 'c', 'o', 'c', 'c', 'c', 'o']
../_images/notebooks_Classification_Test_3_19_58.png
!! d correct=10 wrong= 0 answers=['d', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd']
../_images/notebooks_Classification_Test_3_19_60.png
!! e correct= 4 wrong= 6 answers=['e', 'o', 'e', 'o', 'o', 'o', 'e', 'o', 'o', 'e']
../_images/notebooks_Classification_Test_3_19_62.png
!! f correct= 0 wrong=10 answers=['I', 'I', 'I', 'I', 'i', 'I', 'I', 'I', 'I', 'I']
../_images/notebooks_Classification_Test_3_19_64.png
!! g correct=10 wrong= 0 answers=['g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g']
../_images/notebooks_Classification_Test_3_19_66.png
!! h correct=10 wrong= 0 answers=['h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h']
../_images/notebooks_Classification_Test_3_19_68.png
!! i correct= 8 wrong= 2 answers=['i', 'i', 'i', 'I', 'i', 'i', 'i', 'i', 'I', 'i']
../_images/notebooks_Classification_Test_3_19_70.png
!! j correct= 7 wrong= 3 answers=['j', 'j', 'j', 'I', 'I', 'j', 'j', 'j', 'j', 'I']
../_images/notebooks_Classification_Test_3_19_72.png
!! k correct=10 wrong= 0 answers=['k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k']
../_images/notebooks_Classification_Test_3_19_74.png
!! l correct= 0 wrong=10 answers=['I', 'i', 'I', 'I', 'I', 'I', 'i', 'I', 'I', 'i']
../_images/notebooks_Classification_Test_3_19_76.png
!! m correct=10 wrong= 0 answers=['m', 'm', 'm', 'm', 'm', 'm', 'm', 'm', 'm', 'm']
../_images/notebooks_Classification_Test_3_19_78.png
!! n correct= 5 wrong= 5 answers=['u', 'n', 'n', 'n', 'n', 'n', 'u', 'u', 'u', 'h']
../_images/notebooks_Classification_Test_3_19_80.png
!! o correct=10 wrong= 0 answers=['o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o']
../_images/notebooks_Classification_Test_3_19_82.png
!! p correct=10 wrong= 0 answers=['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p']
../_images/notebooks_Classification_Test_3_19_84.png
!! q correct= 9 wrong= 1 answers=['q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'g']
../_images/notebooks_Classification_Test_3_19_86.png
!! r correct=10 wrong= 0 answers=['r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r']
../_images/notebooks_Classification_Test_3_19_88.png
!! s correct=10 wrong= 0 answers=['s', 's', 's', 's', 's', 's', 's', 's', 's', 's']
../_images/notebooks_Classification_Test_3_19_90.png
!! t correct= 0 wrong=10 answers=['I', 'r', 'I', 'i', 'I', 'i', 'i', 'i', 'I', 'i']
../_images/notebooks_Classification_Test_3_19_92.png
!! u correct=10 wrong= 0 answers=['u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u']
../_images/notebooks_Classification_Test_3_19_94.png
!! v correct=10 wrong= 0 answers=['v', 'v', 'v', 'v', 'v', 'v', 'v', 'v', 'v', 'v']
../_images/notebooks_Classification_Test_3_19_96.png
!! w correct=10 wrong= 0 answers=['w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w']
../_images/notebooks_Classification_Test_3_19_98.png
!! x correct=10 wrong= 0 answers=['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']
../_images/notebooks_Classification_Test_3_19_100.png
!! y correct=10 wrong= 0 answers=['y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y']
../_images/notebooks_Classification_Test_3_19_102.png
!! z correct=10 wrong= 0 answers=['z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z']
../_images/notebooks_Classification_Test_3_19_104.png
!! 0 correct=10 wrong= 0 answers=['0', '0', '0', '0', '0', '0', '0', '0', '0', '0']
../_images/notebooks_Classification_Test_3_19_106.png
!! 1 correct= 5 wrong= 5 answers=['1', 'I', '1', 'I', '1', '1', 'I', 'I', '1', 'I']
../_images/notebooks_Classification_Test_3_19_108.png
!! 2 correct=10 wrong= 0 answers=['2', '2', '2', '2', '2', '2', '2', '2', '2', '2']
../_images/notebooks_Classification_Test_3_19_110.png
!! 3 correct=10 wrong= 0 answers=['3', '3', '3', '3', '3', '3', '3', '3', '3', '3']
../_images/notebooks_Classification_Test_3_19_112.png
!! 4 correct=10 wrong= 0 answers=['4', '4', '4', '4', '4', '4', '4', '4', '4', '4']
../_images/notebooks_Classification_Test_3_19_114.png
!! 5 correct=10 wrong= 0 answers=['5', '5', '5', '5', '5', '5', '5', '5', '5', '5']
../_images/notebooks_Classification_Test_3_19_116.png
!! 6 correct=10 wrong= 0 answers=['6', '6', '6', '6', '6', '6', '6', '6', '6', '6']
../_images/notebooks_Classification_Test_3_19_118.png
!! 7 correct= 7 wrong= 3 answers=['7', '7', '7', 'I', '7', 'I', 'I', '7', '7', '7']
../_images/notebooks_Classification_Test_3_19_120.png
!! 8 correct= 4 wrong= 6 answers=['8', '6', '6', '6', '8', 'd', '8', '8', 'd', '6']
../_images/notebooks_Classification_Test_3_19_122.png
!! 9 correct= 3 wrong= 7 answers=['9', '0', '6', '0', '9', '0', '0', '9', '0', '0']

3.8.4. Testing with low noise

In [17]:
for x in 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789':
    iter_read(x, p=0.05)
../_images/notebooks_Classification_Test_3_21_0.png
!! A correct=10 wrong= 0 answers=['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A']
../_images/notebooks_Classification_Test_3_21_2.png
!! B correct=10 wrong= 0 answers=['B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B']
../_images/notebooks_Classification_Test_3_21_4.png
!! C correct=10 wrong= 0 answers=['C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C']
../_images/notebooks_Classification_Test_3_21_6.png
!! D correct=10 wrong= 0 answers=['D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D']
../_images/notebooks_Classification_Test_3_21_8.png
!! E correct=10 wrong= 0 answers=['E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E']
../_images/notebooks_Classification_Test_3_21_10.png
!! F correct=10 wrong= 0 answers=['F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F']
../_images/notebooks_Classification_Test_3_21_12.png
!! G correct=10 wrong= 0 answers=['G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G']
../_images/notebooks_Classification_Test_3_21_14.png
!! H correct=10 wrong= 0 answers=['H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H']
../_images/notebooks_Classification_Test_3_21_16.png
!! I correct=10 wrong= 0 answers=['I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I']
../_images/notebooks_Classification_Test_3_21_18.png
!! J correct=10 wrong= 0 answers=['J', 'J', 'J', 'J', 'J', 'J', 'J', 'J', 'J', 'J']
../_images/notebooks_Classification_Test_3_21_20.png
!! K correct=10 wrong= 0 answers=['K', 'K', 'K', 'K', 'K', 'K', 'K', 'K', 'K', 'K']
../_images/notebooks_Classification_Test_3_21_22.png
!! L correct=10 wrong= 0 answers=['L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L']
../_images/notebooks_Classification_Test_3_21_24.png
!! M correct=10 wrong= 0 answers=['M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M']
../_images/notebooks_Classification_Test_3_21_26.png
!! N correct=10 wrong= 0 answers=['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N']
../_images/notebooks_Classification_Test_3_21_28.png
!! O correct=10 wrong= 0 answers=['O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O']
../_images/notebooks_Classification_Test_3_21_30.png
!! P correct=10 wrong= 0 answers=['P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P']
../_images/notebooks_Classification_Test_3_21_32.png
!! Q correct=10 wrong= 0 answers=['Q', 'Q', 'Q', 'Q', 'Q', 'Q', 'Q', 'Q', 'Q', 'Q']
../_images/notebooks_Classification_Test_3_21_34.png
!! R correct=10 wrong= 0 answers=['R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R']
../_images/notebooks_Classification_Test_3_21_36.png
!! S correct=10 wrong= 0 answers=['S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S']
../_images/notebooks_Classification_Test_3_21_38.png
!! T correct=10 wrong= 0 answers=['T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T']
../_images/notebooks_Classification_Test_3_21_40.png
!! U correct=10 wrong= 0 answers=['U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U']
../_images/notebooks_Classification_Test_3_21_42.png
!! V correct=10 wrong= 0 answers=['V', 'V', 'V', 'V', 'V', 'V', 'V', 'V', 'V', 'V']
../_images/notebooks_Classification_Test_3_21_44.png
!! W correct=10 wrong= 0 answers=['W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W']
../_images/notebooks_Classification_Test_3_21_46.png
!! X correct=10 wrong= 0 answers=['X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X']
../_images/notebooks_Classification_Test_3_21_48.png
!! Y correct=10 wrong= 0 answers=['Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y']
../_images/notebooks_Classification_Test_3_21_50.png
!! Z correct=10 wrong= 0 answers=['Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z']
../_images/notebooks_Classification_Test_3_21_52.png
!! a correct=10 wrong= 0 answers=['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']
../_images/notebooks_Classification_Test_3_21_54.png
!! b correct= 7 wrong= 3 answers=['b', 'b', 'b', 'h', 'b', 'o', 'b', 'h', 'b', 'b']
../_images/notebooks_Classification_Test_3_21_56.png
!! c correct=10 wrong= 0 answers=['c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c']
../_images/notebooks_Classification_Test_3_21_58.png
!! d correct=10 wrong= 0 answers=['d', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd']
../_images/notebooks_Classification_Test_3_21_60.png
!! e correct= 9 wrong= 1 answers=['e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'o', 'e']
../_images/notebooks_Classification_Test_3_21_62.png
!! f correct= 6 wrong= 4 answers=['i', 'f', 'f', 'I', 'I', 'I', 'f', 'f', 'f', 'f']
../_images/notebooks_Classification_Test_3_21_64.png
!! g correct=10 wrong= 0 answers=['g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g']
../_images/notebooks_Classification_Test_3_21_66.png
!! h correct=10 wrong= 0 answers=['h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h']
../_images/notebooks_Classification_Test_3_21_68.png
!! i correct=10 wrong= 0 answers=['i', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'i']
../_images/notebooks_Classification_Test_3_21_70.png
!! j correct=10 wrong= 0 answers=['j', 'j', 'j', 'j', 'j', 'j', 'j', 'j', 'j', 'j']
../_images/notebooks_Classification_Test_3_21_72.png
!! k correct=10 wrong= 0 answers=['k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k']
../_images/notebooks_Classification_Test_3_21_74.png
!! l correct= 0 wrong=10 answers=['i', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'i']
../_images/notebooks_Classification_Test_3_21_76.png
!! m correct=10 wrong= 0 answers=['m', 'm', 'm', 'm', 'm', 'm', 'm', 'm', 'm', 'm']
../_images/notebooks_Classification_Test_3_21_78.png
!! n correct=10 wrong= 0 answers=['n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n']
../_images/notebooks_Classification_Test_3_21_80.png
!! o correct=10 wrong= 0 answers=['o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o']
../_images/notebooks_Classification_Test_3_21_82.png
!! p correct=10 wrong= 0 answers=['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p']
../_images/notebooks_Classification_Test_3_21_84.png
!! q correct=10 wrong= 0 answers=['q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q']
../_images/notebooks_Classification_Test_3_21_86.png
!! r correct=10 wrong= 0 answers=['r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r']
../_images/notebooks_Classification_Test_3_21_88.png
!! s correct=10 wrong= 0 answers=['s', 's', 's', 's', 's', 's', 's', 's', 's', 's']
../_images/notebooks_Classification_Test_3_21_90.png
!! t correct= 9 wrong= 1 answers=['t', 't', 't', 't', 't', 't', 't', 'i', 't', 't']
../_images/notebooks_Classification_Test_3_21_92.png
!! u correct=10 wrong= 0 answers=['u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u']
../_images/notebooks_Classification_Test_3_21_94.png
!! v correct=10 wrong= 0 answers=['v', 'v', 'v', 'v', 'v', 'v', 'v', 'v', 'v', 'v']
../_images/notebooks_Classification_Test_3_21_96.png
!! w correct=10 wrong= 0 answers=['w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w']
../_images/notebooks_Classification_Test_3_21_98.png
!! x correct=10 wrong= 0 answers=['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']
../_images/notebooks_Classification_Test_3_21_100.png
!! y correct=10 wrong= 0 answers=['y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y']
../_images/notebooks_Classification_Test_3_21_102.png
!! z correct=10 wrong= 0 answers=['z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z']
../_images/notebooks_Classification_Test_3_21_104.png
!! 0 correct=10 wrong= 0 answers=['0', '0', '0', '0', '0', '0', '0', '0', '0', '0']
../_images/notebooks_Classification_Test_3_21_106.png
!! 1 correct=10 wrong= 0 answers=['1', '1', '1', '1', '1', '1', '1', '1', '1', '1']
../_images/notebooks_Classification_Test_3_21_108.png
!! 2 correct=10 wrong= 0 answers=['2', '2', '2', '2', '2', '2', '2', '2', '2', '2']
../_images/notebooks_Classification_Test_3_21_110.png
!! 3 correct=10 wrong= 0 answers=['3', '3', '3', '3', '3', '3', '3', '3', '3', '3']
../_images/notebooks_Classification_Test_3_21_112.png
!! 4 correct=10 wrong= 0 answers=['4', '4', '4', '4', '4', '4', '4', '4', '4', '4']
../_images/notebooks_Classification_Test_3_21_114.png
!! 5 correct=10 wrong= 0 answers=['5', '5', '5', '5', '5', '5', '5', '5', '5', '5']
../_images/notebooks_Classification_Test_3_21_116.png
!! 6 correct=10 wrong= 0 answers=['6', '6', '6', '6', '6', '6', '6', '6', '6', '6']
../_images/notebooks_Classification_Test_3_21_118.png
!! 7 correct=10 wrong= 0 answers=['7', '7', '7', '7', '7', '7', '7', '7', '7', '7']
../_images/notebooks_Classification_Test_3_21_120.png
!! 8 correct= 9 wrong= 1 answers=['8', '6', '8', '8', '8', '8', '8', '8', '8', '8']
../_images/notebooks_Classification_Test_3_21_122.png
!! 9 correct= 7 wrong= 3 answers=['9', '9', '0', '9', '9', '9', '0', '0', '9', '9']

3.8.5. Testing with no noise

In [18]:
for x in 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789':
    iter_read(x, p=0, n=1)
../_images/notebooks_Classification_Test_3_23_0.png
!! A correct= 1 wrong= 0 answers=['A']
../_images/notebooks_Classification_Test_3_23_2.png
!! B correct= 1 wrong= 0 answers=['B']
../_images/notebooks_Classification_Test_3_23_4.png
!! C correct= 1 wrong= 0 answers=['C']
../_images/notebooks_Classification_Test_3_23_6.png
!! D correct= 1 wrong= 0 answers=['D']
../_images/notebooks_Classification_Test_3_23_8.png
!! E correct= 1 wrong= 0 answers=['E']
../_images/notebooks_Classification_Test_3_23_10.png
!! F correct= 1 wrong= 0 answers=['F']
../_images/notebooks_Classification_Test_3_23_12.png
!! G correct= 1 wrong= 0 answers=['G']
../_images/notebooks_Classification_Test_3_23_14.png
!! H correct= 1 wrong= 0 answers=['H']
../_images/notebooks_Classification_Test_3_23_16.png
!! I correct= 1 wrong= 0 answers=['I']
../_images/notebooks_Classification_Test_3_23_18.png
!! J correct= 1 wrong= 0 answers=['J']
../_images/notebooks_Classification_Test_3_23_20.png
!! K correct= 1 wrong= 0 answers=['K']
../_images/notebooks_Classification_Test_3_23_22.png
!! L correct= 1 wrong= 0 answers=['L']
../_images/notebooks_Classification_Test_3_23_24.png
!! M correct= 1 wrong= 0 answers=['M']
../_images/notebooks_Classification_Test_3_23_26.png
!! N correct= 1 wrong= 0 answers=['N']
../_images/notebooks_Classification_Test_3_23_28.png
!! O correct= 1 wrong= 0 answers=['O']
../_images/notebooks_Classification_Test_3_23_30.png
!! P correct= 1 wrong= 0 answers=['P']
../_images/notebooks_Classification_Test_3_23_32.png
!! Q correct= 1 wrong= 0 answers=['Q']
../_images/notebooks_Classification_Test_3_23_34.png
!! R correct= 1 wrong= 0 answers=['R']
../_images/notebooks_Classification_Test_3_23_36.png
!! S correct= 1 wrong= 0 answers=['S']
../_images/notebooks_Classification_Test_3_23_38.png
!! T correct= 1 wrong= 0 answers=['T']
../_images/notebooks_Classification_Test_3_23_40.png
!! U correct= 1 wrong= 0 answers=['U']
../_images/notebooks_Classification_Test_3_23_42.png
!! V correct= 1 wrong= 0 answers=['V']
../_images/notebooks_Classification_Test_3_23_44.png
!! W correct= 1 wrong= 0 answers=['W']
../_images/notebooks_Classification_Test_3_23_46.png
!! X correct= 1 wrong= 0 answers=['X']
../_images/notebooks_Classification_Test_3_23_48.png
!! Y correct= 1 wrong= 0 answers=['Y']
../_images/notebooks_Classification_Test_3_23_50.png
!! Z correct= 1 wrong= 0 answers=['Z']
../_images/notebooks_Classification_Test_3_23_52.png
!! a correct= 1 wrong= 0 answers=['a']
../_images/notebooks_Classification_Test_3_23_54.png
!! b correct= 1 wrong= 0 answers=['b']
../_images/notebooks_Classification_Test_3_23_56.png
!! c correct= 1 wrong= 0 answers=['c']
../_images/notebooks_Classification_Test_3_23_58.png
!! d correct= 1 wrong= 0 answers=['d']
../_images/notebooks_Classification_Test_3_23_60.png
!! e correct= 1 wrong= 0 answers=['e']
../_images/notebooks_Classification_Test_3_23_62.png
!! f correct= 1 wrong= 0 answers=['f']
../_images/notebooks_Classification_Test_3_23_64.png
!! g correct= 1 wrong= 0 answers=['g']
../_images/notebooks_Classification_Test_3_23_66.png
!! h correct= 1 wrong= 0 answers=['h']
../_images/notebooks_Classification_Test_3_23_68.png
!! i correct= 1 wrong= 0 answers=['i']
../_images/notebooks_Classification_Test_3_23_70.png
!! j correct= 1 wrong= 0 answers=['j']
../_images/notebooks_Classification_Test_3_23_72.png
!! k correct= 1 wrong= 0 answers=['k']
../_images/notebooks_Classification_Test_3_23_74.png
!! l correct= 0 wrong= 1 answers=['i']
../_images/notebooks_Classification_Test_3_23_76.png
!! m correct= 1 wrong= 0 answers=['m']
../_images/notebooks_Classification_Test_3_23_78.png
!! n correct= 1 wrong= 0 answers=['n']
../_images/notebooks_Classification_Test_3_23_80.png
!! o correct= 1 wrong= 0 answers=['o']
../_images/notebooks_Classification_Test_3_23_82.png
!! p correct= 1 wrong= 0 answers=['p']
../_images/notebooks_Classification_Test_3_23_84.png
!! q correct= 1 wrong= 0 answers=['q']
../_images/notebooks_Classification_Test_3_23_86.png
!! r correct= 1 wrong= 0 answers=['r']
../_images/notebooks_Classification_Test_3_23_88.png
!! s correct= 1 wrong= 0 answers=['s']
../_images/notebooks_Classification_Test_3_23_90.png
!! t correct= 1 wrong= 0 answers=['t']
../_images/notebooks_Classification_Test_3_23_92.png
!! u correct= 1 wrong= 0 answers=['u']
../_images/notebooks_Classification_Test_3_23_94.png
!! v correct= 1 wrong= 0 answers=['v']
../_images/notebooks_Classification_Test_3_23_96.png
!! w correct= 1 wrong= 0 answers=['w']
../_images/notebooks_Classification_Test_3_23_98.png
!! x correct= 1 wrong= 0 answers=['x']
../_images/notebooks_Classification_Test_3_23_100.png
!! y correct= 1 wrong= 0 answers=['y']
../_images/notebooks_Classification_Test_3_23_102.png
!! z correct= 1 wrong= 0 answers=['z']
../_images/notebooks_Classification_Test_3_23_104.png
!! 0 correct= 1 wrong= 0 answers=['0']
../_images/notebooks_Classification_Test_3_23_106.png
!! 1 correct= 1 wrong= 0 answers=['1']
../_images/notebooks_Classification_Test_3_23_108.png
!! 2 correct= 1 wrong= 0 answers=['2']
../_images/notebooks_Classification_Test_3_23_110.png
!! 3 correct= 1 wrong= 0 answers=['3']
../_images/notebooks_Classification_Test_3_23_112.png
!! 4 correct= 1 wrong= 0 answers=['4']
../_images/notebooks_Classification_Test_3_23_114.png
!! 5 correct= 1 wrong= 0 answers=['5']
../_images/notebooks_Classification_Test_3_23_116.png
!! 6 correct= 1 wrong= 0 answers=['6']
../_images/notebooks_Classification_Test_3_23_118.png
!! 7 correct= 1 wrong= 0 answers=['7']
../_images/notebooks_Classification_Test_3_23_120.png
!! 8 correct= 1 wrong= 0 answers=['8']
../_images/notebooks_Classification_Test_3_23_122.png
!! 9 correct= 1 wrong= 0 answers=['9']